package com.COMP3111H.project;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.TextView;

public class More_InfoCredit extends Activity implements View.OnClickListener {
	TextView tvHeadLine1, tvHeadLine2, tvHeadLine3;
	WebView tvPara1, tvPara2, tvPara3, tvPara4;
	Button bPara1, bPara2, bPara3, bPara4;
	final int HELP = 0;
	Button menu;

	boolean para1_OnClick = false, para2_OnClick = false,
			para3_OnClick = false, para4_OnClick = false;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.more_infocredit);
		initializer();
		menu = (Button) findViewById(R.id.moreinfocredit_menu);
		menu.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				 String[] choices={"Home","View My Profile","Help","Cancel"};  
				             AlertDialog dialog = new AlertDialog.Builder(More_InfoCredit.this)  
				                     // .setIcon(android.R.drawable.btn_star)  
				                      .setTitle("Menu")  
				                      .setItems(choices, onselect_logged).create();  
				             dialog.show();  
			}
		});
	}
	
	OnClickListener onselect_logged = new OnClickListener() {
		public void onClick(DialogInterface dialog, int which) {
			// TODO Auto-generated method stub
			Intent myIntent;
			switch (which) {
			case 0:
				myIntent = new Intent(More_InfoCredit.this, Home.class);
				startActivity(myIntent);
				break;
			case 1:
				myIntent = new Intent(More_InfoCredit.this, My_Profile.class);
				startActivity(myIntent);
				break;
			case 2:
				myIntent = new Intent(More_InfoCredit.this, Help.class);
				startActivity(myIntent);
				break;
			case 3:
				dialog.dismiss();
				break;
			}
		}
	};

	private void initializer() {
		// TODO Auto-generated method stub
		tvPara1 = (WebView) findViewById(R.id.tv_More_Infocredit_para1_content);
		(bPara1 = (Button) findViewById(R.id.b_More_Infocredit_para1))
				.setOnClickListener(this);
		tvPara2 = (WebView) findViewById(R.id.tv_More_Infocredit_para2_content);
		(bPara2 = (Button) findViewById(R.id.b_More_Infocredit_para2))
				.setOnClickListener(this);
		tvPara3 = (WebView) findViewById(R.id.tv_More_Infocredit_para3_content);
		(bPara3 = (Button) findViewById(R.id.b_More_Infocredit_para3))
				.setOnClickListener(this);
		tvPara4 = (WebView) findViewById(R.id.tv_More_Infocredit_para4_content);
		(bPara4 = (Button) findViewById(R.id.b_More_Infocredit_para4))
				.setOnClickListener(this);
	}

	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.b_More_Infocredit_para1:
			if (!para1_OnClick) {
				tvPara1.loadData(shtml_Para1, "text/html", "utf-8");
				para1_OnClick = true;
			} else {
				para1_OnClick = false;
				tvPara1.loadData("", "text/html", "utf-8");
			}
			break;
			
		case R.id.b_More_Infocredit_para2:
			if (!para2_OnClick) {
				tvPara2.loadData(shtml_Para2, "text/html", "utf-8");
				para2_OnClick = true;
			} else {
				para2_OnClick = false;
				tvPara2.loadData("", "text/html", "utf-8");
			}
			break;
			
		case R.id.b_More_Infocredit_para3:
			if (!para3_OnClick) {
				tvPara3.loadData(shtml_Para3, "text/html", "utf-8");
				para3_OnClick = true;
			} else {
				para3_OnClick = false;
				tvPara3.loadData("", "text/html", "utf-8");
			}
			break;
			
		case R.id.b_More_Infocredit_para4:
			if (!para4_OnClick) {
				tvPara4.loadData(shtml_Para4, "text/html", "utf-8");
				para4_OnClick = true;
			} else {
				para4_OnClick = false;
				tvPara4.loadData("", "text/html", "utf-8");
			}
			break;
		}
	}

	String shtml_Para1 = 
			"<UL style=\"margin-left:0px;  padding-left:20px;\" >"+
			"<LI><font  size=\"1\"> You need only 1 BookWarm credit to freely</font>"
			+ "<LI ><font  size=\"1\"> To-the-door book delivery service (#)!</font>"
			
			+ "<LI> <font  size=\"1\">To-be fully returned deposit is needed when you get the book. "
			+ "Check out More Info about Deposit</font>"
			
			+ "<LI> <font  size=\"1\">For books owned by BookWarm, you could freely write or highlight "
			+ "the book as long as the usability of the book is not affected. However, "
			+ "for books owned by other students, writing or highlighting on the book is "
			+ "not permitted.</font>"+
			"</UL>";
	String shtml_Para2 = 
			"<UL style=\"margin-left:0px;  padding-left:20px;\" >"+
			"<LI><font  size=\"1\">To-the-door book pickup and return service (#): Save Your Time and Energy.</font>"
			
			+ "<LI><font  size=\"1\">One-click away book listing process because we have the database of most of the "
			+ "popular used books.</font>"
			
			+ "<LI><font  size=\"1\">Whenever your book is borrowed by others, you will get <b>1 more "
			+ "BookWarm Credit awarded!</b> Use these credits to borrow books from others "
			+ "for free! That is the point of SHARING!</font>"
			
			+ "<LI><font  size=\"1\">Whenever you list 2 more books on our website, <b>1 more BookWarm Credit</b> "
			+ "will be awarded as well! And, listing books on BookWarm is so EASY and FAST "
			+ "(One-Click away).</font>"+
			"</UL>";
	String shtml_Para3 = 
			"<UL style=\"margin-left:0px;  padding-left:20px;\" >"+
			"<LI><font  size=\"1\">If your book is lost or misused or broken badly, "
			+ "a compensation of HKD 200 will be issued to you</font>"
			
			+ "<LI><font  size=\"1\">If the condition of your book is considerably worse after "
			+ "you get it back, a compensation of up to HKD 200 will be given</font>"
	+"</UL>";
	String shtml_Para4 = 
			"<UL style=\"margin-left:0px;  padding-left:20px;\" >"+
			"<LI><font  size=\"1\">BookWarm credit will be kept throughout your stay in "
			+ "HKUST and you could use them whenever you want.</font>"
			
			+ "<LI><font  size=\"1\">After each semester, if you have extra credits on your "
			+ "balance that you do not want, you may contact BookWarm and "
			+ "BookWarm could buy your credits back. Each credit would "
			+ "be worth up to HKD 50.</font>"
			
			+ "<LI><font  size=\"1\">If you do not have sufficient credit balance but you really "
			+ "need some, you may contact BookWarm and buy some credits. Each "
			+ "credit is worth HKD 30 for this semester. However, this is NOT "
			+ "recommended. Each student would have the up limit for buying "
			+ "credits, and BookWarm could decide not giving credits any more. "
			+ "Lend your books for others, keep the sharing spirit up and "
			+ "earn free credits!</font>"
			+"</UL>";
}
